#include<stdio.h>

int main()
{
	int n = 0;
	scanf_s("%d", &n);
	int num = 0;
	int temp;
	for (int i = 1; i <= n; i++)
	{
		num = i;
		temp = 0;
		while (num)
		{
			temp = temp * 10 + num % 10;
			num /= 10;
		}
		if (i == temp)
		{
			printf("%d\n", i);
		}
	}
	return 0;
}